import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;

public class Main {
    public static void main(String[] args) {

        String jarPath = "file:F:\\Java\\tempProjects\\JavaDemo\\out\\artifacts\\PluginJar\\PluginJar.jar";
        try {
            URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{new URL(jarPath)});
            Class<?> pluginUtl = urlClassLoader.loadClass("PluginUtil");
            System.out.println(pluginUtl);

            Object obj = pluginUtl.newInstance();
            Method method = pluginUtl.getDeclaredMethod("hi");
            method.invoke(obj);
        } catch (Exception e) {
            System.out.println("fail. " +e.getMessage());
            e.printStackTrace();
        }


    }
}

